package com.sgu6.sgu6_machine.base;

import android.app.Activity;
import android.app.AlarmManager;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;

import com.sgu6.sgu6_machine.App;
import com.sgu6.sgu6_machine.config.MachineConfig;

import java.util.ArrayList;
import java.util.List;

public abstract class BaseA extends AppCompatActivity {

    public final String TAG = this.getClass().getSimpleName();
    protected App app = new App();
    public MachineConfig machineConfig = new MachineConfig();

    public AlarmManager am;
    public List<Activity> activities = new ArrayList<>();

    public abstract void initUI();


    @RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
    public void setFullScreen() {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);

//        View decorView = getWindow().getDecorView();
//        int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
//                | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_FULLSCREEN;
//        decorView.setSystemUiVisibility(uiOptions);

        Window _window = getWindow();
        WindowManager.LayoutParams params = _window.getAttributes();
        params.systemUiVisibility = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE;
        _window.setAttributes(params);
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        am = (AlarmManager) getSystemService(ALARM_SERVICE);
        app.addActivity(this);
    }

    public void updateConfig() {
        try {
            machineConfig.updateMachineConfig(this);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
